// ============================================================================
//
// Copyright (C) 2009-2011 SC Technology Group. - www.sc.com
//
// ============================================================================
package com.cs.vessel.breakdown.view.providers;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

import com.sc.vessel.info.model.breakdown.Component;

public class ComponentViewContentProvider implements IStructuredContentProvider, ITreeContentProvider {

    public void inputChanged(Viewer v, Object oldInput, Object newInput) {
    }

    public void dispose() {
    }

    public Object[] getElements(Object parent) {
        return (Object[]) parent;
    }

    public Object getParent(Object child) {
        return null;
    }

    public Object[] getChildren(Object parentElement) {
        if (parentElement instanceof Component) {
            Component component = (Component) parentElement;
            return component.getComponents().toArray();
        }
        return null;
    }

    public boolean hasChildren(Object parent) {
        if (parent instanceof Component) {
            Component component = (Component) parent;
            if (component.getComponents().size() != 0) {
                return true;
            }
        }
        return false;
    }
}
